<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
<head>
    <meta charset="UTF-8">
    <title>zTree增加节点</title>

    <base href="http://localhost/shop-resources/back/">

    <script type="text/javascript" src="lib/jquery/1.9.1/jquery.js"></script>
    <script type="text/javascript" src="lib/layer/layer.js"></script>
    <script type="text/javascript" src="js/AjaxUtil.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#add").click(function () {
                var pid = $("#pid").val();
                var goodsTypeName = $("#goodsTypeName").val();
                    // alert(goodsTypeName);
                alert(pid);
                //判断是否是根节点
                if ($("#isRoot").prop("checked")){
                    pid = -1;
                }

                var param = new Object();
                param.goodsTypeName = goodsTypeName;
                param.goodsTypePid = pid;
                // alert(param.goodsTypeName);
                send("shop-back/goodsTypeController/addGoodsType",param,function (resp) {
                    if (resp.status == "success") {
                        // 关闭并刷新
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        window.parent.location.reload();
                    }
                });
            })
        })
    </script>
</head>
<body>
<input type="hidden" id="pid" th:value="${id}">
<input type="checkbox" id="isRoot" value="-1">是否是根节点<br/>
节点名称:<input type="text" id="goodsTypeName">
<button id="add">添加</button>
</body>
</html>